<style scoped>
    .main {
        height: 100%;
    }

    .main >>> .hd-logo {
        width: auto;
        height: 100%;
    }

    .main >>> .layout-logo {
        width: 36%;
    }

    .home-login {
        color: white;
        font-size: 18px;
        font-weight: bold;
        cursor: pointer;
    }

    .home-name {
        color: white;
        font-size: 18px;
        font-weight: bold;
        margin-right: 4px;
    }
</style>

<template>
    <div class="main">
        <main-theme1
                :logoPath="logoImage"
                :siderWidth="220"
                ref="mainTheme"
                :headerMenusShow="closeHeaderMenu"
                >
            <template slot="headerRight">
                <div class="home-name">{{ getUserName }} |</div>
                <div class="home-login" @click="logout">退出登录</div>
            </template>
            <router-view></router-view>
        </main-theme1>
    </div>
</template>

<script>

import { mapActions } from 'vuex'
import { userMenuList } from '@/api/user.js'
import logo from '@/assets/images/logo.png'
import logo1 from '@/assets/images/header.png'
import logo2 from '@/assets/images/header_03.png'

export default {
  data () {
    return {
      userInfo: [],
      userMenu: [],
      closeHeaderMenu: true,
      logoImage: logo
    }
  },
  methods: {
    ...mapActions([
      'getUserInfo',
      'getPhpMenusData',
      'getJavaMenusData',
      'setBreadCrumb'
    ]),
    logout () {
      this.$refs.mainTheme.logout()
    }
  },
  computed: {
    getUserName () {
      return this.$store.state.user.severUserInfo.data.name + '(' + this.$store.state.user.severUserInfo.data.bind_seller_login_code + ')'
    }
  },
  mounted () {
    this.getUserInfo().then(res => {
      // console.log('userInfo', res)
      if (res.errcode === 0) {
        this.userInfo = res.data
        // this.closeHeaderMenu = this.userInfo.loginName === 'L0002'
        if (this.userInfo.loginName === 'LA000465') {
          this.logoImage = logo1
        }
        if (this.userInfo.loginName === 'LA00513') {
          this.logoImage = logo2
        }
      } else {
        this.$Message.error('获取登录信息失败')
      }
    })
    userMenuList().then(res => {
      if (res.data.errcode === 0) {
        this.userMenu = res.data.data
        if (this.userMenu.length > 0) {
          this.getJavaMenusData(this.userMenu[0].parent_ids)
        }
      } else {
        this.$Message.error('获取一级菜单信息失败')
      }
    })
    if (this.$config.phpMenu) {
      this.getPhpMenusData(1)
    } else {
      // TODO 如果是java菜单还需要调用综合菜单-id需要自己配置
      // const firstMenu = this.$store.state.app.menuHeaderListData && this.$store.state.app.menuHeaderListData[0]
      // if (firstMenu) {
      //   this.getJavaMenusData(firstMenu.parent_ids)
      // }
      // this.getJavaMenusData('0,1,8a059c02-5bae-11ea-9069-0242ac11003a')
    }
  }
}
</script>
